/*
 * File Name: RendererHelper.java
 * Created on: November 14, 2007, 11:19 AM
 */

package co.edu.uniandes.intercon.client.gui.cell;

import java.awt.Color;

import javax.swing.JComponent;
import javax.swing.JTable;

import co.edu.uniandes.intercon.server.core.Constants;

/**
 * Utility class used to change the colors of a specified row in a table
 * 
 * @author Fabian Gutierrez [fabian.gutierrez@itac.com.co]
 */
public class RendererHelper {
    
    /**
     * Change the color of the row of a grid depending on the row position.
     * 
     * @param renderer  Rendered used to overwrite the color
     * @param table     Table containing the row
     * @param row       Row to paint
     */
    public static void changeColors(JComponent renderer, final JTable table, final int row) {
        if (row%2==0) {//odd
            renderer.setBackground(Constants.ODD_COLOR);
        } else {
            renderer.setBackground(Color.WHITE);
        }
        
        if(table.getSelectedRow()==row){
            renderer.setBackground(Constants.SELECTED_COLOR);
        }
    }
    
}
